<?php
/**
 * Created by PhpStorm.
 * User: kongxf
 * Date: 2016/1/5
 * Time: 13:15
 */
ini_set("display_errors", "on");
ini_set("memory_limit","1024M");
set_time_limit(0);
include_once(dirname(__FILE__).'/../include/lxbase.class.php');

$dbconfig = Lxbase::getconfig('olddb');
$db = new Lxbase($dbconfig);
$res = $db->arrdata('*','dish_order');
foreach($res as $k=>$v){
    if($v['time']<strtotime(date('Y-m-d 00:00:00')) && !$v['ispast'] && !$v['paid']){
        $orderinfo = unserialize($v['info']);
        foreach($orderinfo as $m=>$n){
            if(isset($n['did'])){
                $db->updata('dish','instock = instock + ' . $n['num'],'where id = ' . $n['did']);
            }
        }
        $db->updata('dish_order','ispast=1','where id = ' . $v['id']);
    }
}
echo 'OK';